package com.ai.entity.made.page;

import cn.hutool.core.collection.CollectionUtil;
import com.ai.entity.BasePage;
import com.ai.entity.made.OpcServerInfo;
import com.ai.entity.made.RegionBase;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * @Author jiaok
 * @Date 2024-11-15 14:51
 */
@Data
public class OpcServerInfoPage extends BasePage<OpcServerInfo> {

    @ApiModelProperty(value = "opc名称")
    private String opcServerName;

    @ApiModelProperty(value = "opcServerIp")
    private String ip;

    private String port;

    @ApiModelProperty(value = "连接方式 1:匿名登录，2:账号密码")
    private String connectMode;

    @ApiModelProperty("组织id")
    private List<String> regionBaseIdList;

    @Override
    public QueryWrapper<OpcServerInfo> getQuery(QueryWrapper<OpcServerInfo> queryWrapper) {
        return super.getQuery(queryWrapper)
                .like(StringUtils.isNotBlank(opcServerName),"opc_server_name",opcServerName)
                .like(StringUtils.isNotBlank(ip),"ip",ip)
                .like(StringUtils.isNotBlank(port),"port",port)
                .like(StringUtils.isNotBlank(connectMode),"connect_mode",connectMode)
                .in(CollectionUtil.isNotEmpty(regionBaseIdList),"region_base_id",regionBaseIdList)
                .orderByDesc("create_time");
    }
}
